{include file='public/header.html'}

{php $category=widget('common.category')->get()}
<div class="blog container mtn">

    <div class="row">
        <div class="col-sm-9">

            <div class="blog-top">
                {if $page_type==1:}<i class="glyphicon glyphicon-send"></i> 最新文章{/if}
                {if $page_type==2:}<i class="glyphicon glyphicon-th-list"></i> 分类：{$category[$cid]}{/if}
                {if $page_type==3:}<i class="glyphicon glyphicon-search"></i> 关键字： <span class="text-danger">{$keyword}</span>{/if}
                {if $page_type==4:}<i class="glyphicon glyphicon-tags"></i> 标签： <span class="text-danger">#{$tag}</span>{/if}
                <span class="pull-right">共 {$list->attr('total')} 篇文章</span>
            </div>

            <div class="row mtn">

                {php $offset=$list->attr('offset')}
                {foreach $list as $k=>$vo}
                {php $k=$k+1+$offset}
                {if $k<=2 && $page_type==1:}
                <div class="col-sm-6">
                    <div class="media">
                        <div class="media-left media-top">
                            <a href="{:url('article/detail',['id'=>$vo['id']])}"><img src="{:rand_thumb($vo['thumb'], $k)}" alt="thumb" /></a>
                        </div>
                        <div class="media-body">
                            <div class="media-heading">
                                {if $vo['is_top']==1:}<span class="text-danger">置顶</span>{/if} <a href="{:url('article/detail',['id'=>$vo['id']])}">{$vo.title}</a>
                            </div>
                            <div class="media-content">
                                {$vo.summary|str_substr=60}
                            </div>
                            <div class="media-footer">
                                <a href="{:url('article/index',['cid'=>$vo['category_id']])}"><i class="glyphicon glyphicon-th-list"></i> {$category[$vo['category_id']]}</a>
                                <a href="{:url('article/detail',['id'=>$vo['id']])}" class="read pull-right">阅读</a>
                            </div>
                        </div>
                    </div>
                </div>
                {else:}
                <div class="col-sm-12">
                    <div class="media">
                        <div class="media-left media-top">
                            <a href="{:url('article/detail',['id'=>$vo['id']])}"><img src="{:rand_thumb($vo['thumb'], $k)}" alt="thumb" /></a>
                        </div>
                        <div class="media-body">
                            <div class="media-heading">
                                {if $vo['is_top']==1:}<span class="text-danger">置顶</span>{/if} <a href="{:url('article/detail',['id'=>$vo['id']])}">{$vo.title}</a>
                            </div>
                            <div class="media-content">
                                {$vo.summary}
                            </div>
                            <div class="media-footer">
                                <i class="glyphicon glyphicon-user"></i> <a href="{:url('user/info',['id'=>$vo['user_id']])}">{$vo.author}</a>&nbsp;&nbsp;
                                <a href="{:url('article/index',['cid'=>$vo['category_id']])}"><i class="glyphicon glyphicon-th-list"></i> {$category[$vo['category_id']]}</a>&nbsp;&nbsp;
                                <i class="glyphicon glyphicon-time"></i> {:date('Y-m-d', $vo['update_time'])}&nbsp;&nbsp;
                                <i class="glyphicon glyphicon-eye-open"></i> {$vo.read_count}&nbsp;&nbsp;
                                {!empty $vo['tag_ids']:}
                                <span class="pull-right">
                                    {php $tags=widget('common.tags')->get($vo['tag_ids'], ['key'=>'sign'])}
                                    {foreach $tags as $sign=>$name}
                                    <a href="{:url('article/index', ['tag'=>$sign])}">#{$name}</a>&nbsp;&nbsp;
                                    {/foreach}
                                </span>
                                {/empty}
                            </div>
                        </div>
                    </div>
                </div>
                {/if}
                {/foreach}
                {empty $list->toArray():}
                <div class="well" style="margin: 0 15px;">暂无文章！</div>
                {/empty}

            </div>
            {$list->links()}

        </div>

        <div class="col-sm-3">
            {include file='article/inc_sidebar.html'}
        </div>
    </div>

</div>

{include file='public/footer.html'}
<script>
    $(document).ready(function () {
        $('#search').click(function () {
            "" != $("#keyword").val() ? location.href = "{:url('article/index')}?keyword=" + $("#keyword").val() : toast('请输入关键字');
        });
    });
</script>
</body>
</html>